package com.example.conversorcplp;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.example.conversorcplp.Paises;

public class MainActivity extends Activity {

	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
	
		Button btn = (Button) findViewById(R.id.button1);
		Button btn2 = (Button) findViewById(R.id.button2);
		Button btn3 = (Button) findViewById(R.id.button3);
		Button btn4 = (Button) findViewById(R.id.button4);
		Button btn5 = (Button) findViewById(R.id.button5);
		
		btn.setOnClickListener(new OnClickListener(){
		    public void onClick(View v){                        
		        startActivity(new Intent(MainActivity.this, PaisOrigem.class));
		    }
		});
		
		btn2.setOnClickListener(new OnClickListener(){
		    public void onClick(View v){                        
		        startActivity(new Intent(MainActivity.this, PaisDestino.class));
		    }
		});
		
		btn3.setOnClickListener(new OnClickListener(){
		    public void onClick(View v){                        
		        startActivity(new Intent(MainActivity.this, ActualizaTaxas.class));
		    }
		});
		
		btn4.setOnClickListener(new OnClickListener(){
		    public void onClick(View v){                        
		        startActivity(new Intent(MainActivity.this, Conversao.class));
		    }
		});
		btn5.setOnClickListener(new OnClickListener(){
		    public void onClick(View v){                        
		        Paises.paisorigem = null;
		        Paises.paisdestino = null;
		        Rates.kwanzaRate = 102.112;
		    	Rates.brazilRate = 2.693484;
		    	Rates.cverdeRate = 88.208125;
		    	Rates.equaRate = 527.168639;
		    	Rates.guineRate = 7068.545;
		    	Rates.mocambiRate = 33.777525;
		    	Rates.eurRate = 0.806902;
		    	Rates.stpRate = 19703.0;
		    	Rates.timorRate= 1.0;
		    	Rates.usdRate = 1.0;
		    	Toast.makeText(getApplicationContext(), "Definicoes repostas !", Toast.LENGTH_SHORT).show();
		    	onResume();
		    }
		});
	}
	
	@Override   
    protected void onResume() {
		super.onResume();
		String po = Paises.paisorigem;
		String pd = Paises.paisdestino;
		
		TextView textView = (TextView) findViewById(R.id.textView1);
		textView.setText(po);
		
		TextView textView2 = (TextView) findViewById(R.id.textView2);
		textView2.setText(pd);
		
    }
}
